home *** CD-ROM | disk | FTP | other *** search
Wrap
AMOS Source Code | 1996-02-23 | 25.2 KB | 857 lines
' This tutorial is from Mr. AMOS Club ' issue 5, edited by Brian Bell and ' others, which folded in 1994. No ' other group has matched its code ' tutorials before or since. ' ' If run on an NTSC system it must ' be PAL booted to see the bottom of ' the screen. ' ' *********************************************************** ' * Welcome to the third part of our SPACEFIGHTER game. * ' * This game as you know is our attempt at a Body Blows * ' * Street Fighter II style fighting game. I have made * ' * drastic changes to the code of this program since * ' * issue three where we had one of the fighters doing * ' * a few simple movements. That routine was controlled * ' * completely from AMAL which made it VERY fast and smooth * ' * although at the same time VERY complicated and hard * ' * to explain. * ' * * ' * This new demo and the full game now use this new * ' * system instead as its far more friendly and flexible. * ' * Unfortunatley the game nows runs at 25 frames per * ' * second instead of the previous 50 frames per second. * ' * This is because we are not using the speed of AMAL * ' * and we have also opted for half brite mode instead * ' * of 32 colour mode which gives us 64 colours on the * ' * main game screen instead which allowed Ashley to * ' * draw much more detailed backdrops and characters!! * ' * * ' * Body Blows on the AMIGA runs at 25 frames per second * ' * and its only done in 32 colours. Street Fighter II * ' * is only 12.5 frames per seond on the AMIGA and its * ' * only done in 16 colours! The only game that I have * ' * seen that has achieved the 50 frames per second is * ' * Mortal Combat which is done in 16 colours. * ' * * ' * The full SPACEFIGHTER game has 20 new fighters in it * ' * which makes it the BIGGEST fighting game around! * ' * I have advertised it in AMIGA FORMAT and CU AMIGA * ' * for a few months to see how the sales go and I am * ' * also working on a coverdisk version as well. The * ' * full game costs only �5.00 to ALL you loyal members. * ' * This includes the source code although this is * ' * NOT documented as the program is VERY BIG and * ' * optimized. I will be explaining LOTS of different * ' * routines via MAC and next issue we will have the * ' * character fighting another character. I was * ' * hoping to have this version on this issue which * ' * shows you how to get an intelligent computer * ' * controlled opponent. But I have once again ran * ' * completely OUT of disk space! The graphics for * ' * the SPACEFIGHTER game are VERY big space eaters * ' * due to their size and the amount of colours they * ' * have. * ' * * ' * This demo version allows you to do the entire range of * ' * movements that this character has.Just move the joystick* ' * in different directions and press the fire button!! * ' * Hold down the fire button for the special move! * ' *********************************************************** Hide On : Rem Hide the mouse! _____MAIN_____: If Length(15)=0 Then Load "tube_planet.pic" : Rem This loads in the packed picture! ' ******************************************************************** ' * The next few lines take care of upacking the background picture * ' * and score screen. It fades them in to make it more professional! * ' ******************************************************************** Unpack 15 To 0 : Screen Hide 0 For N=0 To 31 : Colour N,$0 : Next N Wait Vbl : Screen Show 0 Double Buffer : Update Off Unpack 10 To 1 : Screen Hide 1 For N=0 To 31 : Colour N,$0 : Next N Wait Vbl Screen Show 1 Screen 1 Fade 2 To -1 : Wait 40 Screen 0 Fade 3 To -1 : Wait 40 ' ************************************************************** ' * This variable stores the amount of animations or different * ' * movements that our fighter has. * ' ************************************************************** AMOUNT_OF_ANIMATIONS=14 ' ******************************************************************** ' * This next lot of DIM statements store all the numbers that are * ' * used in conjunction with our fighter. Our fighter is cutup into * ' * four different parts. A head, a top body, his legs and a hit * ' * part - which can be any of the previous mentioned. Because * ' * the fighters movements are cutup into smaller pieces to save * ' * memory, speed and disk space we must store the different * ' * combinations that it takes to make each movement up as numbers. * ' * All I have done is store these details in DIM statements. * ' ******************************************************************** Dim _PL_1_LEGS(AMOUNT_OF_ANIMATIONS) Dim _PL_1_LEGS_X_OFFSET(AMOUNT_OF_ANIMATIONS) Dim _PL_1_LEGS_Y_OFFSET(AMOUNT_OF_ANIMATIONS) Dim _PL_1_BODY(AMOUNT_OF_ANIMATIONS) Dim _PL_1_BODY_X_OFFSET(AMOUNT_OF_ANIMATIONS) Dim _PL_1_BODY_Y_OFFSET(AMOUNT_OF_ANIMATIONS) Dim _PL_1_HEAD(AMOUNT_OF_ANIMATIONS) Dim _PL_1_HEAD_X_OFFSET(AMOUNT_OF_ANIMATIONS) Dim _PL_1_HEAD_Y_OFFSET(AMOUNT_OF_ANIMATIONS) Dim _PL_1_HIT_PART(AMOUNT_OF_ANIMATIONS) Dim _PL_1_HIT_PART_X_OFFSET(AMOUNT_OF_ANIMATIONS) Dim _PL_1_HIT_PART_Y_OFFSET(AMOUNT_OF_ANIMATIONS) Restore _ANIMATION_DATA For COUNTER=1 To AMOUNT_OF_ANIMATIONS Read _PL_1_LEGS(COUNTER) Read _PL_1_LEGS_X_OFFSET(COUNTER) Read _PL_1_LEGS_Y_OFFSET(COUNTER) Read _PL_1_BODY(COUNTER) Read _PL_1_BODY_X_OFFSET(COUNTER) Read _PL_1_BODY_Y_OFFSET(COUNTER) Read _PL_1_HEAD(COUNTER) Read _PL_1_HEAD_X_OFFSET(COUNTER) Read _PL_1_HEAD_Y_OFFSET(COUNTER) Read _PL_1_HIT_PART(COUNTER) Read _PL_1_HIT_PART_X_OFFSET(COUNTER) Read _PL_1_HIT_PART_Y_OFFSET(COUNTER) Next COUNTER ' ********************************************************************* ' * This DATA stores all the information that is required to build up * ' * the different animations and movements for the character. All I * ' * do is store different X and Y offset coardinates of sprite bank * ' * images. The character in the game is moved around his X and Y * ' * coardinates. Because he is built up of different pieces we must * ' * centre these other pieces around these X and Y coardinates of * ' * the fighter. All we have to do is place them at the fighters * ' * X and Y coardinate and add an X and Y offset to them that * ' * centres the different pieces around him. * ' ********************************************************************* ' ***************************************************************************** ' * As I have already said the fighter is divided into four different pieces. * ' * The following DATA is called in groups of threes. These are the details * ' * required by each of the different fighter parts. * ' * * ' * The first number stores an image number which can be anything. * ' * * ' * The second number stores an X offset which is added to the fighters X * ' * coardinates to centre the image around him. * ' * * ' * The third number stores a Y offset which is added to the fighters y * ' * coardinates to centre the image around him. * ' * * ' * The four sets of numbers are stored as follows:- * ' * * ' * The first set I have used for Legs. * ' * The second set I have used for a top body bit. * ' * The third set I have used for the head. * ' * The fourth set I have used for the HIT part. * ' ***************************************************************************** _ANIMATION_DATA: Data 3,0,0,5,-10,-46,1,17,-55,1,-500,-500 Data 4,-6,5,5,-10,-42,1,17,-51,1,-500,-500 Data 18,-4,21,5,-10,-20,1,17,-29,1,-500,-500 Data 16,-3,26,12,-32,1,2,-2,-6,17,20,23 Data 18,-4,21,8,-1,-20,1,17,-29,1,-500,-500 Data 18,-4,21,9,-12,-20,1,17,-29,10,36,-6 Data 11,0,-2,12,-32,-28,2,-2,-34,19,24,-13 Data 4,-6,5,9,-12,-41,1,17,-50,10,36,-27 Data 6,2,0,7,-1,-40,1,24,-50,1,-500,-500 Data 14,8,0,13,-3,-40,1,23,-50,15,45,-48 Data 16,-3,16,12,-32,-9,2,-2,-16,19,20,6 Data 6,2,0,9,-12,-42,1,17,-49,10,36,-28 Data 16,-4,26,25,20,24,24,8,0,23,70,2 Data 20,-33,4,21,10,-10,22,74,-20,1,42,-12 _FIGHT_START: _PL_1_X=50 : Rem This stores the X position of the fighter on screen _PL_1_Y=158 : Rem This stores the Y position of the fighter on screen _PL_1_ANIMATION=1 : Rem This stores the current animation or movement of the fighter _PL_1_STATUS=1 : Rem This tells us what the fighter is doing at any time _PL_1_SPEED=8 : Rem This is the speed at which he moves around at _PL_1_ANIMATION_SPEED=3 : Rem This is the speed of his walking animations ' ************** ' * Fight Loop * ' ************** _FIGHT_LOOP: Gosub _PL_1_CHECKING : Rem This line jumps to the routine that does all of the checking for Player number 1 ' ********************************************************************* ' * These four lines place the four different parts of the fighter on * ' * the screen according to their different details stored in the * ' * DIM and DATA statements. All I need to do to get a particular * ' * fighting animation is call this routine and give is an ANIMATION * ' * number to place on the screen. * ' ********************************************************************* Bob 1,_PL_1_X+_PL_1_LEGS_X_OFFSET(_PL_1_ANIMATION),_PL_1_Y+_PL_1_LEGS_Y_OFFSET(_PL_1_ANIMATION),_PL_1_LEGS(_PL_1_ANIMATION) Bob 2,_PL_1_X+_PL_1_BODY_X_OFFSET(_PL_1_ANIMATION),_PL_1_Y+_PL_1_BODY_Y_OFFSET(_PL_1_ANIMATION),_PL_1_BODY(_PL_1_ANIMATION) Bob 3,_PL_1_X+_PL_1_HEAD_X_OFFSET(_PL_1_ANIMATION),_PL_1_Y+_PL_1_HEAD_Y_OFFSET(_PL_1_ANIMATION),_PL_1_HEAD(_PL_1_ANIMATION) Bob 4,_PL_1_X+_PL_1_HIT_PART_X_OFFSET(_PL_1_ANIMATION),_PL_1_Y+_PL_1_HIT_PART_Y_OFFSET(_PL_1_ANIMATION),_PL_1_HIT_PART(_PL_1_ANIMATION) Update : Wait Vbl : Rem This line will place ALL our bobs on the screen in their latest positions Goto _FIGHT_LOOP ' ******************************************************* ' * This is where ALL of the fighters checking is done. * ' ******************************************************* _PL_1_CHECKING: _MOVING=0 : Rem Tells is used to tell us if the fighter has moved or not! ' ****************************************************************** ' * When the joystick is pushed up we have to check if it has been * ' * pushed left or right as well. If it has then we must jump to * ' * the appropriate routine. * ' ****************************************************************** If _PL_1_JUMPING>0 If _PL_1_JUMPING=1 : Gosub _JUMPING_UP : End If : Rem Has the fighter just jumped up in a straight line? If _PL_1_JUMPING=2 : Gosub _JUMPING_UP_AND_LEFT : End If : Rem Has the fighter jumped up to the left? If _PL_1_JUMPING=3 : Gosub _JUMPING_UP_AND_RIGHT : End If : Rem Has the fighter jumped up to the right? If _PL_1_JUMPING=4 : Gosub _SPECIAL_MOVE : End If : Rem This line is only used for speed reasons. It controls the SPECIAL move and has nothing to do with jumping! Return End If ' ************************************************************************ ' * When a hit movement has been carried out we need to keep it on the * ' * screen for a while to get the full effect so this bit causes a delay * ' * before it allows the fighter to do any more movements. * ' ************************************************************************ If _HIT_MOVEMENT=1 : Rem Is the fighter currently carring out a HIT movement? Inc _HIT_TIMER : Rem This controls a time delay If _HIT_TIMER>5 : Rem Has then delay been reached? ' ******************************************************* ' * If it has then clear all the appropriate variables. * ' ******************************************************* _HIT_TIMER=0 _HIT_MOVEMENT=0 _HIT_CLEAR_COUNTER=0 : Rem This is used to control another delay in the fighter so that there is a delay between hit movements End If Return End If Inc _HIT_CLEAR_COUNTER : Rem Used to control a delay between HIT movements ' *********************************************** ' * Has the joystick been pressed to the right? * ' *********************************************** If Jright(1) If Fire(1) : Rem Has FIRE been pressed? If _PL_1_STATUS=1 : Rem Is the player currently standing or walking? If _HIT_CLEAR_COUNTER>5 : Rem Is it ok to carry out a HIT movement? ' ************************************* ' * This controls the standing punch! * ' ************************************* _HIT_MOVEMENT=1 : Rem Tell the program that its carrying out a HIT movement _PL_1_ANIMATION=8 : Rem Tell the program what animation to show _MOVING=1 : Rem Tell the program it has moved in this loop Return : Rem Return End If End If End If If _PL_1_X<280 : Rem Is the fighters X coardinates inside the screen? If _PL_1_STATUS=1 : Rem Is he currently standing or walking Add _PL_1_ANIMATION_SPEED_COUNTER,1,1 To _PL_1_ANIMATION_SPEED : Rem This controls his walking animation speed ' ***************************************** ' * This controls the walking animations. * ' ***************************************** If _PL_1_ANIMATION_SPEED_COUNTER=_PL_1_ANIMATION_SPEED Add _PL_1_ANIMATION,1,1 To 2 End If _PL_1_X=_PL_1_X+_PL_1_SPEED : Rem Move him across the screen! _MOVING=1 : Rem Tell the program he is moving! End If End If End If ' ********************************************** ' * Has the joystick been pressed to the left? * ' ********************************************** If Jleft(1) If Fire(1) : Rem Has FIRE been pressed If _PL_1_STATUS=1 : Rem Is the fighter currently standing or walking? If _HIT_CLEAR_COUNTER>5 : Rem Is it OK to carry out a HIT movement? ' ******************************* ' * This controls the SIDEKICK! * ' ******************************* _HIT_MOVEMENT=1 : Rem Tell the program that its carrying out a HIT movement _PL_1_ANIMATION=7 : Rem Tell the program what animation to show _MOVING=1 : Rem Tell the program it has moved in this loop Return : Rem Return End If End If End If If _PL_1_X>10 : Rem Is the fighter inside the screen? If _PL_1_STATUS=1 : Rem Is he currently walking or standing? Add _PL_1_ANIMATION_SPEED_COUNTER,1,1 To _PL_1_ANIMATION_SPEED : Rem This controls his walking animation speed ' ***************************************** ' * This controls the walking animations. * ' ***************************************** If _PL_1_ANIMATION_SPEED_COUNTER=_PL_1_ANIMATION_SPEED Add _PL_1_ANIMATION,1,1 To 2 End If _PL_1_X=_PL_1_X-_PL_1_SPEED : Rem Move him across the screen! _MOVING=1 : Rem Tell the program he is moving! End If End If End If ' ************************************* ' * Has the JOYSTICK been pressed up? * ' ************************************* If Jup(1) _JUMPING=1 : Rem Tell the program that he is jumping _PL_1_ANIMATION=1 : Rem Make sure he is standing still before he jumps If Jright(1) _PL_1_JUMPING=3 : Rem Tell the routine to make Player 1 to jump to the right Return End If If Jleft(1) _PL_1_JUMPING=2 : Rem Tell the routine to make Player 1 jump to the left Return End If _PL_1_JUMPING=1 : Rem Tell the routine to make Player 1 jump up straight Return End If ' *************************************** ' * Has the JOYSTICK been pressed down? * ' *************************************** If Jdown(1) _MOVING=1 : Rem Tell the program he is moving ' ********************************************************************* ' * Has the joystick been press right and fire when down and is it ok * ' * to carry out a hit movement? * ' ********************************************************************* If Fire(1) and Jright(1) and _HIT_CLEAR_COUNTER>5 ' ********************************* ' * This carrys out the HEADBUTT! * ' ********************************* _HIT_MOVEMENT=1 : Rem Tell the program it is carrying out a HIT movement _PL_1_STATUS=2 : Rem Tell the program it is ducking _PL_1_ANIMATION=13 : Rem Show the animation Return End If ' ************************** ' * Has FIRE been pressed? * ' ************************** If Fire(1) If Not Jleft(1) and Not Jright(1) : Rem Make sure the joystick has'nt been pressed to the left or right If _HIT_CLEAR_COUNTER>5 : Rem Can we do a HIT movement? ' ************************** ' * This does the LOW KICK * ' ************************** _HIT_MOVEMENT=1 : Rem Tell the program we're doing a HIT movemnt _PL_1_STATUS=2 : Rem Tell it we are ducking _PL_1_ANIMATION=4 : Rem Show animation number 4 Return End If End If End If ' ************************************************ ' * This is used for the duck blocking animation * ' ************************************************ If Jleft(1) and Not Fire(1) : Rem Have you pressed left and NOT pressed fire? _PL_1_STATUS=2 : Rem Tell the program we are ducking _PL_1_ANIMATION=5 : Rem Show animation number 5 Return End If ' ************************************************* ' * This controls the duck punching hit movement. * ' ************************************************* If Jleft(1) and Fire(1) and _HIT_CLEAR_COUNTER>5 : Rem Has left and fire been pressed and can we do a HIT movement? _HIT_MOVEMENT=1 : Rem Tell the program we are doing a HIT movement! _PL_1_STATUS=2 : Rem Tell the program we are ducking _PL_1_ANIMATION=6 : Rem Show animation number 6 Return End If ' ********************************************************************* ' * If no direction has been pushed except JDOWN on its own then just * ' * show the fighter ducking. * ' ********************************************************************* If(_PL_1_STATUS=1 or _PL_1_STATUS=2) _PL_1_STATUS=2 _PL_1_ANIMATION=3 Return End If Else ' *********************************************************************** ' * If the joystick is let go then we need to make the fighter stand up * ' * again. * ' *********************************************************************** If _PL_1_STATUS=2 : Rem Is he already ducking? _PL_1_STATUS=1 : Rem Tell the program he is now standing _PL_1_ANIMATION=1 : Rem Show the standing animation Return : Rem Return! End If End If ' ******************************************************************* ' * This next bit controls our fighter standing still without doing * ' * any movements. It also checkings for FIRE being held down so * ' * that he does a special movement! * ' ******************************************************************* If _MOVING=0 : Rem Has he moved? - No! _PL_1_ANIMATION=1 : Rem Show him standing! ' ********************************************************* ' * This is the bit that checks for FIRE being held down! * ' ********************************************************* If Fire(1) : Rem Has fire been pressed? Inc _SPECIAL_MOVE_COUNTER : Rem Start couting how many times Else _SPECIAL_MOVE_COUNTER=0 : Rem Fire has not been held down so reset the counter! End If ' ****************************************** ' * This part checks for the SPECIAL MOVE. * ' ****************************************** If _SPECIAL_MOVE_COUNTER=10 : Rem Has FIRE been held down for 10 VBL's _PL_1_JUMPING=4 : Rem This is used to tell the program that a SPECIAL MOVE is being carried out - I have just used the jumping variable to tell the program this! _SPECIAL_MOVE_COUNTER=0 : Rem Reset the counter End If End If Return ' ***************************************************************** ' * This bit controls the fighter JUMPING UP straight in the air! * ' ***************************************************************** _JUMPING_UP: If _PL_1_ANIMATION<>10 : Rem This controls the KICKING in the air bit! _PL_1_ANIMATION=9 End If If _JUMPING=1 : Rem Is the fighter currently moving UP! ' ************************** ' * Has fire been pressed? * ' ************************** If Fire(1) _PL_1_ANIMATION=10 : Rem Show the kicking animation End If _PL_1_Y=_PL_1_Y-_PL_1_SPEED*1.5 : Rem Move him up the screen ' ********************************************************************* ' * Once he reaches the TOP of the screen we just tell the program to * ' * start moving him down again by setting _JUMPING to 0. * ' ********************************************************************* If _PL_1_Y<0 : Rem Reached the top of the screen? _JUMPING=0 End If End If ' ***************************************************** ' * This bit controls the fighter falling down again! * ' ***************************************************** If _JUMPING=0 _PL_1_Y=_PL_1_Y+_PL_1_SPEED*1.5 If _PL_1_Y=158 : Rem Has he reached the ground? _JUMPING=0 : Rem Tell the program that all jumping has stopped _PL_1_JUMPING=0 : Rem Clear this variable _PL_1_ANIMATION=1 : Rem Place the fighters stance animation on screen End If End If Return _JUMPING_UP_AND_LEFT: If _PL_1_ANIMATION<>12 : Rem This controls the kicking in the jump _PL_1_ANIMATION=9 End If If _JUMPING=1 : Rem Is the fighter currently moving up? ' ******************************************************* ' * If you have pressed FIRE then show the FLYING PUNCH * ' ******************************************************* If Fire(1) _PL_1_ANIMATION=12 : Rem Show FLYING PUNCH End If _PL_1_Y=_PL_1_Y-_PL_1_SPEED*1.5 : Rem Move him UP the screen If _PL_1_X>0 _PL_1_X=_PL_1_X-_PL_1_SPEED : Rem If his X coardiantes are greater than 0 then move him to the left End If If _PL_1_Y<20 : Rem Once his Y coardiantes have reached 20 then we start moving him back down again _JUMPING=0 Wait Vbl End If End If If _JUMPING=0 : Rem Is he now falling? _PL_1_Y=_PL_1_Y+_PL_1_SPEED*1.5 : Rem Start moving him down If _PL_1_X>0 _PL_1_X=_PL_1_X-_PL_1_SPEED : Rem If his X coardinates are greater than 0 then move him to the left End If If _PL_1_Y=158 : Rem Has his Y coardinates reached the ground yet? _JUMPING=0 : Rem Clear jumping _PL_1_JUMPING=0 _PL_1_ANIMATION=1 : Rem Place the fighters stance animation on the screen End If End If Return _JUMPING_UP_AND_RIGHT: If _PL_1_ANIMATION<>11 : Rem This controls the FLYING KICK in air _PL_1_ANIMATION=9 End If If _JUMPING=1 : Rem Is the fighter currently moving UP the screen? ' *********************************************************** ' * If FIRE is pressed then show the FLYING KICK animation! * ' *********************************************************** If Fire(1) _PL_1_ANIMATION=11 : Rem Show flying kick End If _PL_1_Y=_PL_1_Y-_PL_1_SPEED*1.5 : Rem Move him UP the screen If _PL_1_X<280 _PL_1_X=_PL_1_X+_PL_1_SPEED : Rem If his X coardinates are less than 280 then move him to the right End If If _PL_1_Y<20 : Rem Has he reached the TOP of the screen yet? _JUMPING=0 : Rem Tell the program to make him start falling! Wait Vbl : Rem A slight PAUSE! End If End If ' ******************************************* ' * This controls him falling to the right! * ' ******************************************* If _JUMPING=0 _PL_1_Y=_PL_1_Y+_PL_1_SPEED*1.5 : Rem Move him down the screen If _PL_1_X<280 _PL_1_X=_PL_1_X+_PL_1_SPEED : Rem If his X coardinates are less than 280 then make him move to the right! End If If _PL_1_Y=158 : Rem Has he reached the ground yet? _JUMPING=0 _PL_1_JUMPING=0 _PL_1_ANIMATION=1 : Rem Show the STANCE animation End If End If Return ' ************************************************** ' * This is the bit that controls the SPECIAL MOVE * ' ************************************************** _SPECIAL_MOVE: _PL_1_ANIMATION=14 : Rem Show SPECIAL MOVE animation Inc _SPECIAL_MOVE_MOVEMENT_COUNTER : Rem This is a timing counter ' **************************************************** ' * Is the fighters X coardinates inside the screen? * ' **************************************************** If _PL_1_X<260 _PL_1_X=_PL_1_X+_PL_1_SPEED*2 : Rem Move him accross the screen VERY FAST Else _SPECIAL_MOVE_MOVEMENT_COUNTER=10 : Rem Otherwise END the SPECIAL MOVE End If ' ************************************************************* ' * Once the SPECIAL MOVE has been on the screen for 10 VBL's * ' * we need to turn it off. * ' ************************************************************* If _SPECIAL_MOVE_MOVEMENT_COUNTER=10 _SPECIAL_MOVE_MOVEMENT_COUNTER=0 _PL_1_ANIMATION=1 : Rem Show the fighters stance animation _PL_1_JUMPING=0 _MOVING=0 : Rem Tell the program that ALL moving has finished End If Return